package com.dc.business.datacollectbusiness.config;

import com.dc.business.datacollectbusiness.incerptors.LoginInterceptoer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptoer loginInterceptoer;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptoer)
                .excludePathPatterns("/api/user/captcha","/api/user/{username}/{password}/{code}",
                        "/images/1.png","/images/2.png","/images/3.png");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 添加静态资源处理器
        registry.addResourceHandler("/static/**")
                // 指定静态资源的位置
                .addResourceLocations("classpath:/static/images");
    }

}
